<?php
/**
 * Created by PhpStorm.
 * User: Alex
 * DateTime: 18-8-23下午3:47
 */

namespace SMSBundle\sms;



use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Config extends Controller
{
    private static $_config = null;

    public static function getSDKConfig(ContainerInterface $container){
        if (Config::$_config == null ) {
            Config::$_config = new Config($container);
        }
        return Config::$_config;
    }

    private $dataBaseTableName;//数据库表名
    private $expireTime;//短信过期时长
    private $usedTime;//短信可用次数
    private $trueSend;//是否调用第三发接口发送
    private $isBeta;//是否显示短信
    private $saltType;//显示短信类新
    private $saltNum;//短信验证码长度

    function __construct(ContainerInterface $container = null)
    {
        $this->setContainer($container);

        $this->dataBaseTableName = $container->hasParameter('SMS_dataBaseTableName') == true ? $this->getParameter('SMS_dataBaseTableName') :'sms_record';
        $this->expireTime = $container->hasParameter('SMS_expireTime') == true ? $this->getParameter('SMS_expireTime'):'900';
        $this->usedTime = $container->hasParameter('SMS_usedTime')== true ? $this->getParameter('SMS_usedTime'):'1';
        $this->trueSend = $container->hasParameter('SMS_trueSend')== true ? $this->getParameter('SMS_trueSend'):'0';

        $this->isBeta = $container->hasParameter('SMS_isBeta')== true ? $this->getParameter('SMS_isBeta'):'0';
        $this->saltType = $container->hasParameter('SMS_saltType')== true ? $this->getParameter('SMS_saltType'):'1';
        $this->saltNum = $container->hasParameter('SMS_saltNum')== true ? $this->getParameter('SMS_saltNum'):'4';
    }

    public function __get($property_name)
    {
        if(isset($this->$property_name))
        {
            return($this->$property_name);
        } else {
            return(NULL);
        }
    }
}